package com.yonyougov.devops.cruxcisupport.util;

import com.yonyougov.devops.cruxcisupport.committest.CommitTestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Slf4j
@Component
public class CodeUtils {

    @Autowired
    private CommitTestService commitTestService;

    /**
     * 生成提测单code
     *
     * @return
     */
    public String genCommitTestCode() {
        // 提测单code生成
        // 生成策略:年月日时分秒+序号,例如:200515062458001
        String code = "";
        Long todayCommitTestNumber = commitTestService.todayCommitTestNumber();// 今天提测数量
        code = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmss")) + (todayCommitTestNumber + 1);
        return code;
    }
}
